<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$title ? $title : '后台管理'}</title>
    <link href="__ADMIN__/css/bootstrap.min.css" rel="stylesheet">
    <link href="__ADMIN__/font-awesome/css/font-awesome.css" rel="stylesheet">
    <link href="__ADMIN__/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__ADMIN__/css/plugins/toastr/toastr.min.css" rel="stylesheet">
    <link href="__ADMIN__/css/animate.css" rel="stylesheet">
    <link href="__ADMIN__/css/style.css" rel="stylesheet">
    <link href="__ADMIN__/css/plugins/footable/footable.core.css" rel="stylesheet">
    <link href="__ADMIN__/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <link href="__ADMIN__/js/plugins/laydate/theme/default/laydate.css">
	<link href="__ADMIN__/seelct2/custom-select.css" rel="stylesheet" type="text/css" />
    {block name='css'}{/block}
</head>
<body>
{block name="body"}
<div id="wrapper">
    <!--  左侧菜单  -->
    <nav class="navbar-default navbar-static-side" role="navigation">
        <div class="sidebar-collapse">
            <ul class="nav metismenu" id="side-menu">
                <li class="nav-header">
                    <div class="dropdown profile-element">
                        <h2 style="color: #ffffff">{:C('WEB_TITLE')}管理后台</h2>
                    </div>
                    <div class="logo-element">
                        IN+
                    </div>
                </li>
                {volist name='menu' id='value' key='all_key'}
                {if (showLeftMenu($value['id']))}
                {volist name='value.leftMenu' id='vo' key='key'}
                <li class="{:leftMenuActive($vo['id'], 2) ? 'active' : ''}">
                    <a href="{$vo.url ? $vo.url : 'javascript: void(0)'}">
                        <i class="fa {$vo.icon ? $vo.icon : 'fa-list'}"></i>
                        <!--  分组菜单  -->
                        <span class="nav-label">{$vo.name}</span>
                        {notempty name="vo.sonMenu"}<span class="fa arrow"></span>{/notempty}
                    </a>
                    {notempty name="vo.sonMenu"}
                    <ul class="nav nav-second-level collapse">
                        {volist name="vo.sonMenu" id="leftV"}
                        <!--  子菜单  -->
                        <li class="{:leftMenuActive($leftV['id'], 3) ? 'active' : ''}"><a href="{$leftV.url|url}">{$leftV.name}</a>
                        </li>
                        {/volist}
                    </ul>
                    {/notempty}
                </li>
                {/volist}
                {/if}
                {/volist}
            </ul>
        </div>
    </nav>

    <!--  顶部菜单  -->
    <div id="page-wrapper" class="gray-bg dashbard-1">
        <div class="row border-bottom">
            <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
                <div class="navbar-header">
                    <a class="navbar-minimalize minimalize-styl-2 btn btn-primary" style="margin-top: 18px"
                       href="javascript: void(0)">
                        <i class="fa fa-bars"></i>
                    </a>
                </div>
                <ul class="nav navbar-nav mr-auto" style="display: block">
                    {volist name="menu" id="vo"}
                    <li style="float: left; font-size: 14px; font-weight: bold; padding-top: 5px;">
                        <a href="{$vo.url|url}">{$vo.name}</a>
                    </li>
                    {/volist}
                </ul>

                <ul class="nav navbar-top-links navbar-right">
                    <li style="padding: 20px">
                        {if condition="isset($company)"}
                        <span class="m-r-sm text-muted">{$company.name}公司</span>
                        
                        <button type="button" class="btn btn-primary btn-sm" data-toggle="modal"
                                data-target="#__COMPANY_DIALOG">
                            切换公司
                        </button>
                        
                        {else}
                        <button type="button" class="btn btn-primary btn-sm" data-toggle="modal"
                                data-target="#__COMPANY_DIALOG">
                            选择公司
                        </button>
                        {/if}
                    </li>
                    <li style="padding: 20px">
                        <span class="m-r-sm text-muted welcome-message">{$Think.session.account}，欢迎来到{:C('WEB_TITLE')}管理后台</span>
                    </li>

                    <li>
                        <a class="right-sidebar-toggle">
                            <i class="fa fa-tasks"></i>
                        </a>
                    </li>
                </ul>
            </nav>
        </div>


        <div class="row wrapper border-bottom white-bg page-heading">
            <div class="col-lg-8">
                {block name="breadcrumbHeader"}
                <h2>{if condition="$currentMenu"}{$currentMenu.name}{/if}</h2>
                {/block}
                {block name="breadcrumb"}
                <ol class="breadcrumb">
                    <li class="breadcrumb-item">
                        <a href="index.html">主页</a>
                    </li>
                    {if condition="$currentMenu"}
                    <li class="breadcrumb-item active">
                        <strong>{$currentMenu.name}</strong>
                    </li>
                    {/if}
                </ol>
                {/block}
            </div>
            <div class="col-lg-4">
                <div class="title-action menu-actions">
                    {block name="action"}{/block}
                </div>
            </div>
        </div>
        {block name="content"}{/block}

        <!--    sidebar-open控制是否显示    -->
        <div id="right-sidebar" class="animated" style="height: 121px" ;>
            <div class="sidebar-container">
                <div class="tab-content">
                    <div class="tab-pane active">
                        <a href="javascript: void(0)" class="function" id="info-set" data-toggle="modal"
                           data-target="#myModal2">修改密码</a>
                        <a href="javascript: void(0)" class="function" id="clear-cache">清理缓存</a>
                        <a href="javascript: void(0)" class="function" id="logout">退出登录</a>
                    </div>
                </div>
            </div>
        </div>
        <!--    修改密码弹框    -->
        <div class="modal inmodal" id="myModal2" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content animated flipInY">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                                class="sr-only">Close</span></button>
                        <h4 class="modal-title">修改密码</h4>
                    </div>
                    <div class="modal-body">
                        <input type="password" class="input-group old_admin_pwd" placeholder="请输入原密码">
                        <input type="password" class="input-group new_admin_pwd" placeholder="请输入新密码"
                               style="margin-top: 10px">
                        <input type="password" class="input-group re_admin_pwd" placeholder="确认密码"
                               style="margin-top: 10px">
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-white close-model" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary" id="confirmUpdateAdminPwd">确认修改</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}
<!--加载公司弹窗-->
{block name="company"}
{include file="Public:company_select" /}
{/block}
</body>

<script src="__ADMIN__/js/jquery-3.1.1.min.js"></script>
<script src="__ADMIN__/js/plugins/validate/jquery.validate.min.js"></script>
<script src="__STATIC__/layer/layer.js"></script>
<script src="__ADMIN__/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="__ADMIN__/js/common.js"></script>

<!--index.js-->
<script src="__ADMIN__/js/popper.min.js"></script>
<script src="__ADMIN__/js/bootstrap.js"></script>
<script src="__ADMIN__/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="__ADMIN__/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>

<script src="__ADMIN__/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="__ADMIN__/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__ADMIN__/js/plugins/laydate/laydate.js"></script>
<script src="__ADMIN__/js/inspinia.js"></script>
<script src="__ADMIN__/js/plugins/pace/pace.min.js"></script>
<script src="__ADMIN__/js/plugins/toastr/toastr.min.js"></script>
<script src="__ADMIN__/components/toast.js"></script>
<script src="__ADMIN__/js/modal-dialog.js"></script>
<script charset="utf-8" src="https://map.qq.com/api/gljs?v=1.exp&key=T6WBZ-JRKC3-VGI3X-Y7P2R-Y6TTV-GTBVG"></script>
<script src="__ADMIN__/js/tencent-map.js"></script>

{block name='js'}
{/block}
<!--    选择公司js    -->
<script type="text/javascript">
    $(document).ready(function () {
        if ("{$__MUST_SHOW_SELECT_COMPANY__}" !== '') {
            $('#__COMPANY_DIALOG').modal('show');
            getCompany(1);
        }

        function getCompany(options) {
            let url = "{:url('admin/company/dialogCompany')}";
            if (typeof options === 'object') {
                if (options.url) {
                    url = options.url;
                } else {
                    url = url + '?' + $.param(options);
                }
            } else {
                url = url + '?page=' + options;
            }
            $.get(url, function (data, status) {
                $('#__COMPANY_DIALOG_BODY').html(data);
                btnBindEvent();
            })
        }

        $('#__COMPANY_DIALOG').on('show.bs.modal', function (event) {
            getCompany(1);
        })

        function btnBindEvent() {
            $(".company-table-list").on("click", ".company-choice", function (e) {
                let dataId = $(e.currentTarget).data("id");
                $.ajax({
                    url: "{:url('/admin/system/updateCompany')}?companyId=" + dataId,
                    type: "get",
                    success: function (data) {
                        console.log(data);
                        if (data.code === 1) {
                            $('#__COMPANY_DIALOG').modal('hide');
                            window.location.reload();
                        } else {
                            layer.msg(data.msg, {icon: 2, time: 2000});
                        }
                    },
                    error: function (data) {
                        // layer.msg(data.msg, {icon: 2, time: 2000});
                        console.log(data);
                    }
                });
            });
            $(".__company_global_data_list__").on("click", "a", function (e) {
                e.preventDefault();
                const options = {};
                options['url'] = $(this).attr('href');
                getCompany(options);
            });
        }
    })
</script>
</html>